package com.kx.smsplantform.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;

/**
 * @Author Sun
 * @Date 2021/7/2 11:28
 */
@FeignClient(value = "SMSPLATFORM-CACHE")
public interface CacheClient {

    @GetMapping("/cache/hget/{key}/{field}")
    String hGet(@PathVariable String key, @PathVariable String field);

    @RequestMapping(value = "/cache/smembers/{key}", method = RequestMethod.GET)
    Set<String> smembers(@PathVariable("key") String key);

    @RequestMapping(value = "/cache/smembers/{key}", method = RequestMethod.GET)
    Set<Map> smembersMap(@PathVariable String key);

    // set结构的add操作
    @PostMapping(value = "/cache/sadd/{key}")
    boolean sAdd(@PathVariable(value = "key") String key, @RequestParam String... set);

    //查询两个set结构是否有交集
    @GetMapping("/cache/sintersect/{key1}/{key2}")
    Set<String> sIntersect(@PathVariable(value = "key1")String key1,@PathVariable(value = "key2") String key2);

    //从Zset中查询一定范围的数据
    @GetMapping("/cache/limit/{key}")
    Set limit(@PathVariable String key,@RequestParam Long startTime,@RequestParam Long endTime);

    @RequestMapping(value = "/cache/get/{key}", method = RequestMethod.GET)
    String get(@PathVariable("key") String key);

    @GetMapping("/cache/zsave/{key}")
    void zsave(@PathVariable String key,@RequestParam long time,@RequestParam String  randomUUID);

    @PostMapping("/cache/hincr/{key}/{field}/{value}")
    Long hincr(@PathVariable String key,@PathVariable String field,@PathVariable long value);
}
